package com.hz.ruoyilgorder.config;

import com.hz.rouyigonggong.domain.LgInboundOrder;
import com.hz.rouyigonggong.domain.dto.LgInboundOrderDTO;

/**
 * @version 1.0
 * @Author yzw
 * @Date 2025/3/8 15:50
 * @注释
 */
public class LgInboundOrderConverter {

    /**
     * 将 LgInboundOrder 转换为 LgInboundOrderDTO
     */
    public static LgInboundOrderDTO toDTO(LgInboundOrder order) {
        if (order == null) {
            return null;
        }
        LgInboundOrderDTO dto = new LgInboundOrderDTO();
        dto.setInboundId(order.getInboundId());
        dto.setOrderNumber(order.getOrderNumber());
        dto.setSellerId(order.getSellerId());
        dto.setGoodsId(order.getGoodsId());
        dto.setVerifiedWeight(order.getVerifiedWeight());
        dto.setActualQuantity(order.getActualQuantity());
        dto.setUnitId(order.getUnitId());
        dto.setSubId(order.getSubId());
        dto.setInboundDate(order.getInboundDate());
        dto.setExpiryDate(order.getExpiryDate());
        dto.setSellerSignature(order.getSellerSignature());
        dto.setStatus(order.getStatus());
        dto.setCreateBy(order.getCreateBy());
        dto.setUpdateBy(order.getUpdateBy());
        dto.setCreateTime(order.getCreateTime());
        dto.setUpdateTime(order.getUpdateTime());
        dto.setDeleteStatus(order.getDeleteStatus());
        dto.setParams(order.getParams());

        // DTO 额外字段，视情况赋值
        dto.setSellerName(null);  // 需要从其他服务或数据库获取
        dto.setSellerContact(null);
        dto.setGoodsName(null);
        dto.setGoodsUnit(null);
        dto.setColdName(null);
        dto.setSubName(null);
        dto.setDriverName(null);
        dto.setProvidedWeight(null);

        return dto;
    }

    /**
     * 将 LgInboundOrderDTO 转换为 LgInboundOrder
     */
    public static LgInboundOrder toEntity(LgInboundOrderDTO dto) {
        if (dto == null) {
            return null;
        }
        LgInboundOrder order = new LgInboundOrder();
        order.setInboundId(dto.getInboundId());
        order.setOrderNumber(dto.getOrderNumber());
        order.setSellerId(dto.getSellerId());
        order.setGoodsId(dto.getGoodsId());
        order.setVerifiedWeight(dto.getVerifiedWeight());
        order.setActualQuantity(dto.getActualQuantity());
        order.setUnitId(dto.getUnitId());
        order.setSubId(dto.getSubId());
        order.setInboundDate(dto.getInboundDate());
        order.setExpiryDate(dto.getExpiryDate());
        order.setSellerSignature(dto.getSellerSignature());
        order.setStatus(dto.getStatus());
        order.setCreateBy(dto.getCreateBy());
        order.setUpdateBy(dto.getUpdateBy());
        order.setCreateTime(dto.getCreateTime());
        order.setUpdateTime(dto.getUpdateTime());
        order.setDeleteStatus(dto.getDeleteStatus());
//        order.setParams(dto.getParams());

        return order;
    }
}
